!function(e, t) {
    e.tapHandling = !1,
    e.tappy = !0;
    var n = function(n) {
        return n.each(function() {
            function n(e) {
                t(e.target).trigger("tap", [e, t(e.target).attr("href")])
            }
            function i(e) {
                var t = e.originalEvent || e,
                n = t.touches || t.targetTouches;
                return n ? [n[0].pageX, n[0].pageY] : null
            }
            function s(e) {
                if (e.touches && e.touches.length > 1 || e.targetTouches && e.targetTouches.length > 1) return ! 1;
                var t = i(e);
                c = t[0],
                u = t[1]
            }
            function r(e) {
                if (!l) {
                    var t = i(e);
                    t && (Math.abs(u - t[1]) > d || Math.abs(c - t[0]) > d) && (l = !0)
                }
            }
            function a(t) {
                if (clearTimeout(o), o = setTimeout(function() {
                    e.tapHandling = !1,
                    l = !1
                },
                1e3), !(t.which && t.which > 1 || t.shiftKey || t.altKey || t.metaKey || t.ctrlKey)) {
                    if (t.preventDefault(), l || e.tapHandling && e.tapHandling !== t.type) return void(l = !1);
                    e.tapHandling = t.type,
                    n(t)
                }
            }
            var o, u, c, l, p = t(this),
            d = 10;
            p.bind("touchstart.tappy MSPointerDown.tappy", s).bind("touchmove.tappy MSPointerMove.tappy", r).bind("touchend.tappy MSPointerUp.tappy", a).bind("click.tappy", a)
        })
    },
    i = function(e) {
        return e.unbind(".tappy")
    };
    if (t.event && t.event.special) t.event.special.tap = {
        add: function() {
            n(t(this))
        },
        remove: function() {
            i(t(this))
        }
    };
    else {
        var s = t.fn.bind,
        r = t.fn.unbind;
        t.fn.bind = function(e) {
            return /(^| )tap( |$)/.test(e) && n(this),
            s.apply(this, arguments)
        },
        t.fn.unbind = function(e) {
            return /(^| )tap( |$)/.test(e) && i(this),
            r.apply(this, arguments)
        }
    }
} (this, jQuery)
